package de.tu_darmstadt.gdi1.xcom.model.elements;

import de.tu_darmstadt.gdi1.framework.utils.Point;
import de.tu_darmstadt.gdi1.xcom.controller.events.ActionEnum;

public abstract class Mob implements GameElement{

	private int health;
	private int points;
	protected DirectionEnum direction;
	protected Point position;
	protected int initialPoints;
	
	protected int meeleDamage;
	/**
	 * 
	 */
	private static final long serialVersionUID = -4061483133662503692L;

	public int getMeeleDamage() {
		return meeleDamage;
	}

	public void setMeeleDamage(int meeleDamage) {
		this.meeleDamage = meeleDamage;
	}

	public Mob(int x, int y){
		position = new Point(x, y);
		direction = DirectionEnum.North;
	}
	
	public Mob(int x, int y, DirectionEnum initDirection, int initHealth, int initPoints) {
		position = new Point(x, y);
		direction = initDirection;
		health = initHealth;
		initialPoints = initPoints;
	}
	
	public abstract GameElement clone();
	
	public ActionEnum getMoveAction(DirectionEnum dir) {
		return ActionEnum.getMoveAction(direction, dir);
	}
	
	public int getHealth() {
		return health;	
	}
	
	public int getPoints() {
		return points;
	}

	public Point getPosition() {
		return position;
	}
	
	public void setPosition(Point p) {
		position = p;
	}
	
	public void changePosition(Point p) {
		position = new Point(position.getX() + p.getX(), position.getY() + p.getY());
	}
	
	public DirectionEnum getDirection() {
		return direction;
	}
	
	public void setDirection(DirectionEnum newDirection) {
		direction = newDirection;
	}
	
	public void decrementPoints(int decrement) {
		points -= decrement;
	}
	
	public void resetPoints() {
		points = initialPoints;
	}

	public void rotateRight() {
		switch(direction){
			case North: direction = DirectionEnum.East;break;
			case East: direction = DirectionEnum.South;break;
			case South: direction = DirectionEnum.West;break;
			case West: direction = DirectionEnum.North;break;
		}
	}

	public void rotateLeft() {
		switch(direction){
			case North: direction = DirectionEnum.West;break;
			case West: direction = DirectionEnum.South;break;
			case South: direction = DirectionEnum.East;break;
			case East: direction = DirectionEnum.North;break;
		}
	}
	@Override
	public boolean isSolid(){
		return true;
	}
	
	public boolean decrimentHealth(int damage){
		if(damage > health){
			health = 0;
		}
		else
			health -= damage;
		return health <= 0;
	}
	
	public void healMob(int health){
		this.health += health;
	}
}
